<template>
  <div>
    <el-button type="primary" icon="el-icon-video-play" size="small" @click="changeMusiclist">播放</el-button>
    <el-button icon="el-icon-folder-add" size="small">收藏热门50</el-button>
    <SongList :songs="songs" />
  </div>
</template>

<script>
import SongList from '@/components/SongList/SongList.vue';
export default {
  name: "ArtistPopWork",
  data() {
    return {
      songs: [],
    };
  },
  mounted() {
    this.$API.artistTopSong(this.$route.query.id).then(res => {
      if (res.data.code == 200) {
        this.songs = res.data.songs;
      }
    });
  },
  components: { SongList },
  methods: {
    changeMusiclist() {
      this.$bus.$emit('changeMusiclist', this.songs);
    }
  },
  watch:{
    // 监视路由变化，更新数据
    '$route'(){
      this.$API.artistTopSong(this.$route.query.id).then(res => {
        if (res.data.code == 200) {
          this.songs = res.data.songs;
        }
      });
    }
  }
}
</script>

<style lang="less" scoped>
</style>